#include "SettingsWnd.h"
#include "HostStatusWnd.h"
#include "LocationWnd.h"
#include "PersonalComboWnd.h"

BOOL SettingsWnd::OnInitDialog(){
    if (!CMzWndEx::OnInitDialog()){
        return FALSE;
    }

    m_ScrollWin.SetPos(0,0, GetWidth(), GetHeight());
    m_ScrollWin.SetID(SM_IDC_SCROLLWIN_SETTINGS);
    m_ScrollWin.EnableScrollBarV(true);
    AddUiWin(&m_ScrollWin);

    int y=0;
    m_Caption_Personal.SetPos(0, y, GetWidth(), MZM_HEIGHT_CAPTION);
    m_Caption_Personal.SetText(SM_TEXT_CAPTION_PERSONAL_SETTING);
    m_ScrollWin.AddChild(&m_Caption_Personal);
    
    y+=MZM_HEIGHT_CAPTION;
    m_Btn_Status.SetPos(0, y, GetWidth(), MZM_HEIGHT_BUTTONEX);
    m_Btn_Status.SetID(SM_IDC_BTNEX_STATUS);
    m_Btn_Status.SetText(SM_TEXT_BTNEX_STATUS);
    m_Btn_Status.SetButtonType(MZC_BUTTON_LINE_BOTTOM);
    m_ScrollWin.AddChild(&m_Btn_Status);

    y+=MZM_HEIGHT_BUTTONEX;
    m_Btn_Location.SetPos(0, y, GetWidth(), MZM_HEIGHT_BUTTONEX);
    m_Btn_Location.SetID(SM_IDC_BTNEX_LOCATION);
    m_Btn_Location.SetText(SM_TEXT_BTNEX_LOCATION);
    m_Btn_Location.SetButtonType(MZC_BUTTON_LINE_BOTTOM);
    m_ScrollWin.AddChild(&m_Btn_Location);

    y+=MZM_HEIGHT_BUTTONEX;
    m_Btn_Combo.SetPos(0, y, GetWidth(), MZM_HEIGHT_BUTTONEX);
    m_Btn_Combo.SetID(SM_IDC_BTNEX_COMBO);
    m_Btn_Combo.SetText(SM_TEXT_BTNEX_COMBO);
    m_Btn_Combo.SetButtonType(MZC_BUTTON_LINE_BOTTOM);
    m_ScrollWin.AddChild(&m_Btn_Combo);

    y+=MZM_HEIGHT_BUTTONEX;
    m_Caption_System.SetPos(0, y, GetWidth(), MZM_HEIGHT_CAPTION);
    m_Caption_System.SetText(SM_TEXT_CAPTION_SYSTEM_SETTING);
    m_ScrollWin.AddChild(&m_Caption_System);

    m_Toolbar.SetPos(0, GetHeight()-MZM_HEIGHT_TEXT_TOOLBAR, GetWidth(), MZM_HEIGHT_TEXT_TOOLBAR);
    m_Toolbar.SetButton(0, true, true, SM_TEXT_TOOLBAR_CANCEL);
    m_Toolbar.SetButton(2, true, true, SM_TEXT_TOOLBAR_OK);
    m_Toolbar.SetID(SM_IDC_TOOLBAR_SAVE);
    AddUiWin(&m_Toolbar);

    return TRUE;

};

void SettingsWnd::OnMzCommand(WPARAM wParam, LPARAM lParam){
    UINT_PTR id = LOWORD(wParam);
    switch(id){
        case SM_IDC_BTNEX_STATUS:{
            HostStatusWnd hsDlg;
            RECT rect = MzGetWindowRect();
            hsDlg.Create(rect.left, rect.top, RECT_WIDTH(rect), RECT_HEIGHT(rect), m_hWnd, 0, WS_POPUP);
            hsDlg.SetAnimateType_Show(MZ_ANIMTYPE_SCROLL_BOTTOM_TO_TOP_2);
            hsDlg.SetAnimateType_Hide(MZ_ANIMTYPE_SCROLL_TOP_TO_BOTTOM_1);
            int nRet = hsDlg.DoModal();
            if (nRet == ID_OK){
            };
            break;
            }
        case SM_IDC_BTNEX_LOCATION:{
            LocationWnd locationDlg;
            RECT rect = MzGetWindowRect();
            locationDlg.Create(rect.left, rect.top, RECT_WIDTH(rect), RECT_HEIGHT(rect), m_hWnd, 0, WS_POPUP);
            locationDlg.SetAnimateType_Show(MZ_ANIMTYPE_SCROLL_BOTTOM_TO_TOP_2);
            locationDlg.SetAnimateType_Hide(MZ_ANIMTYPE_SCROLL_TOP_TO_BOTTOM_1);
            int nRet = locationDlg.DoModal();
            if (nRet == ID_OK){
            };
            break;
            }
        case SM_IDC_BTNEX_COMBO:{
            PersonalComboWnd pcDlg;
            RECT rect = MzGetWindowRect();
            pcDlg.Create(rect.left, rect.top, RECT_WIDTH(rect), RECT_HEIGHT(rect), m_hWnd, 0, WS_POPUP);
            pcDlg.SetAnimateType_Show(MZ_ANIMTYPE_SCROLL_BOTTOM_TO_TOP_2);
            pcDlg.SetAnimateType_Hide(MZ_ANIMTYPE_SCROLL_TOP_TO_BOTTOM_1);
            int nRet = pcDlg.DoModal();
            if (nRet == ID_OK){
            };
            break;
            }
    };

    return EndModal(ID_CANCEL);
};

MZ_IMPLEMENT_DYNAMIC(SettingsWnd);